package com.zsk.shop.controller.app;

import com.zsk.shop.common.base.BaseResponse;
import com.zsk.shop.service.AliPayAccountUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * @author Ys
 * @date 2021年12月10日 11:10
 */
@RestController
@Api(tags = "商城-支付宝账户")
@RequestMapping("/shop/aliPayAccount")
public class ShopAliPayAccountController {
    @Resource
    private AliPayAccountUserService alipayAccountUserService;

    @GetMapping("/add.do")
    @ApiOperation("填写用户支付宝账户")
    @ApiImplicitParam(name = "accountName", value = "支付宝账户:邮箱/手机号码", required = true)
    public BaseResponse add(@Validated @NotNull(message = "支付宝账号不能为空") String accountName) {
        return alipayAccountUserService.add(accountName);
//        return BaseResponse.error("暂不支持支付宝提现， 请选择银行卡方式提现。");
    }

    @PostMapping("/info.do")
    @ApiOperation("获取用户支付宝账户")
    public BaseResponse info() {
        return alipayAccountUserService.info();
    }

    @GetMapping("/delete.do")
    @ApiOperation("解绑用户支付宝数据")
    @ApiImplicitParam(name = "id", value = "对应id", required = true)
    public BaseResponse delete(@Validated @NotNull(message = "参数不能为空") Long id) {
        return alipayAccountUserService.delete(id);
    }
}
